-----------------------------------------------------------
-- LUA Hearts of Iron 3 Switzerland File
-- Created By: Lothos
-- Modified By: Lothos
-- Date Last Modified: 7/12/2010
-----------------------------------------------------------

local P = {}
AI_SCH = P

function P.HandleMobilization(minister)
	-- Do not do anything as we never want to mobilize
end


-- Production Weights
--   1.0 = 100% the total needs to equal 1.0
function P.ProductionWeights(minister)
	local laArray
	local ministerCountry = minister:GetCountry()
	
	if ministerCountry:IsAtWar() then
		laArray = {
			0.65, -- Land
			0.05, -- Air
			0.00, -- Sea
			0.30}; -- Other
	else
		laArray = {
			0.40, -- Land
			0.10, -- Air
			0.00, -- Sea
			0.50}; -- Other
	end
	
	return laArray
end

-- FORTS --------------------------------------------------
-- Switzerland, wedged in between the French, German and Italian frontiers, is prepearing to strengthen her mountain defences. On the heights of 13,669-high, snow capped Jungfrau she is building a fortress equipped with a heavy guns to belch fire at enemy palnes.
-- From its gun bases on clear days Swiss artillerymen may take the range of targets as far away as the Vosges mountains in France and the Bleck Forest in Germany
function P.Build_Fort(ic, minister, vbGoOver)
	ic = Support.Build_Fort(ic, minister, 3556, 1, vbGoOver) -- Aalst - weak defence along Albert Canal
	return ic
end

function P.Build_AntiAir(ic, minister, vbGoOver)
	ic = Support.Build_AntiAir(ic, minister, 3556, 2, vbGoOver)
	return ic
end
------------------------------------------------------------

function P.DiploScore_InviteToFaction(liScore, voAI, voActorTag, voRecipientTag, voObserverTag)
	-- Stay out of the war, we do not care whats happening around us
	if not(voRecipientTag:GetCountry():IsAtWar()) then
		score = 0
	end
	
	return score
end

function P.DiploScore_Alliance(liScore, voAI, voActorTag, voRecipientTag, voObserverTag)
	-- Stay out of the war, we do not care whats happening around us
	if not(voRecipientTag:GetCountry():IsAtWar()) then
		liScore = 0
	end
	
	return liScore	
end

function P.DiploScore_DemandMilitaryAccess(liScore, voAI, voActorTag, voRecipientTag, voObserverTag)
	-- Stay out of the war, we do not care whats happening around us
	if not(voRecipientTag:GetCountry():IsAtWar()) then
		liScore = 0
	end
	
	return liScore	
end

function P.DiploScore_OfferMilitaryAccess(liScore, voAI, voActorTag, voRecipientTag, voObserverTag)
	-- Stay out of the war, we do not care whats happening around us
	if not(voRecipientTag:GetCountry():IsAtWar()) then
		liScore = 0
	end
	
	return liScore	
end

-- Create very highly trained troops
function P.CallLaw_training_laws(minister, voCurrentLaw)
	local _SPECIALIST_TRAINING_ = 30
	return CLawDataBase.GetLaw(_SPECIALIST_TRAINING_)
end

function P.DiploScore_ConsiderAccess(score, ai, actor, recipient, observer)
	if not(recipient:GetCountry():IsAtWar()) then
		return 0
	end
end


function P.Call_ForeignMinister_Tick(minister)
	local ministerTag = minister:GetCountryTag()
	local ministerCountry = ministerTag:GetCountry()

	-- war with axis diplomacy
	if ministerCountry:GetRelation(CCountryDataBase.GetTag("GER")):HasWar() or ministerCountry:GetRelation(CCountryDataBase.GetTag("ITA")):HasWar() then
		local ai = minister:GetOwnerAI()
		local loAction = CInfluenceAllianceLeader(ministerTag, CCurrentGameState.GetFaction("allies"):GetFactionLeader())
			
		if loAction:IsSelectable() then
			ai:PostAction(loAction)
		end

		local loTagArray = {}
		loTagArray[1] = CCountryDataBase.GetTag("FRA")
		loTagArray[2] = CCountryDataBase.GetTag("ENG")
		--loTagArray[3] = CCountryDataBase.GetTag("ITA")
		
		for i = 1, table.getn(loTagArray) do
		
			if not(ministerCountry:HasDiplomatEnroute(loTagArray[i]))
			and loTagArray[i]:GetCountry():Exists()
			and loTagArray[i]:IsReal()
			and loTagArray[i]:IsValid() then	
		
				local loRelation = ministerCountry:GetRelation(loTagArray[i])
			
					if not(loRelation:HasAlliance()) then
						local loAction = CAllianceAction(ministerTag, loTagArray[i])
				
					if loAction:IsSelectable() then
						local liScore = DiploScore_Alliance(ai, ministerTag, loTagArray[i], loTagArray[i])
					
						if liScore > 50 then
							ai:PostAction(loAction)
						end
					end
				end
			end
		end
	end

end


return AI_SCH